package org.ushio.nchu_22201408.controller;

import org.ushio.common_module.entity.CustomerServiceRating;
import org.ushio.common_module.entity.CustomerServiceRecord;
import org.ushio.nchu_22201408.Feign.ServiceOnlineRecordClient;
import org.ushio.nchu_22201408.service.CustomerServiceRatingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/customer-service-ratings")
public class CustomerServiceRatingController {

    private final CustomerServiceRatingService customerServiceRatingService;
    private final ServiceOnlineRecordClient serviceOnlineRecordClient;

    @Autowired
    public CustomerServiceRatingController(CustomerServiceRatingService customerServiceRatingService,
                                           ServiceOnlineRecordClient serviceOnlineRecordClient) {
        this.customerServiceRatingService = customerServiceRatingService;
        this.serviceOnlineRecordClient = serviceOnlineRecordClient;
    }


    @PostMapping("/insertCustomerServiceRatingController")
    public String createCustomerServiceRating(@RequestBody CustomerServiceRating rating) {
        customerServiceRatingService.createRating(rating);
        return "Customer service rating created successfully";
    }
    @GetMapping("/recordsByPhoneNumber")
    public List<CustomerServiceRecord> getCustomerServiceRecordsByPhoneNumber(@RequestParam String phoneNumber) {
        List<CustomerServiceRecord> result = serviceOnlineRecordClient.getServiceOnlineRecordByPhoneNumber(phoneNumber);
        return result;
    }

}